﻿using System;
using System.ComponentModel;

namespace NanoMvvm.ComponentModel
{
    public abstract class WrapperPropertyDescriptorBase : PropertyDescriptor
    {
        protected WrapperPropertyDescriptorBase(PropertyDescriptor root)
            : base(root)
        {
            Wrapped = root;
        }

        public override AttributeCollection Attributes
        {
            get
            {
                return Wrapped.Attributes;
            }
        }

        public override string Category
        {
            get
            {
                return Wrapped.Category;
            }
        }

        public override Type ComponentType
        {
            get { return Wrapped.ComponentType; }
        }

        public override TypeConverter Converter
        {
            get
            {
                return Wrapped.Converter;
            }
        }

        public override string Description
        {
            get
            {
                return Wrapped.Description;
            }
        }

        public override bool DesignTimeOnly
        {
            get
            {
                return Wrapped.DesignTimeOnly;
            }
        }

        public override string DisplayName
        {
            get
            {
                return Wrapped.DisplayName;
            }
        }

        public override bool IsBrowsable
        {
            get
            {
                return Wrapped.IsBrowsable;
            }
        }

        public override bool IsLocalizable
        {
            get
            {
                return Wrapped.IsLocalizable;
            }
        }

        public override bool IsReadOnly
        {
            get { return Wrapped.IsReadOnly; }
        }

        public override string Name
        {
            get
            {
                return Wrapped.Name;
            }
        }

        public override Type PropertyType
        {
            get { return Wrapped.PropertyType; }
        }

        public override bool SupportsChangeEvents
        {
            get
            {
                return Wrapped.SupportsChangeEvents;
            }
        }

        protected PropertyDescriptor Wrapped { get; private set; }

        public override void AddValueChanged(object component, EventHandler handler)
        {
            Wrapped.AddValueChanged(component, handler);
        }

        public override bool CanResetValue(object component)
        {
            return Wrapped.CanResetValue(component);
        }

        public override bool Equals(object obj)
        {
            return Wrapped.Equals(obj);
        }

        public override PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter)
        {
            return Wrapped.GetChildProperties(instance, filter);
        }

        public override object GetEditor(Type editorBaseType)
        {
            return Wrapped.GetEditor(editorBaseType);
        }

        public override int GetHashCode()
        {
            return Wrapped.GetHashCode();
        }

        public override object GetValue(object component)
        {
            return Wrapped.GetValue(component);
        }

        public override void RemoveValueChanged(object component, EventHandler handler)
        {
            Wrapped.RemoveValueChanged(component, handler);
        }

        public override void ResetValue(object component)
        {
            Wrapped.ResetValue(component);
        }

        public override void SetValue(object component, object value)
        {
            Wrapped.SetValue(component, value);
        }

        public override bool ShouldSerializeValue(object component)
        {
            return Wrapped.ShouldSerializeValue(component);
        }

        public override string ToString()
        {
            return Wrapped.ToString();
        }
    }
}